package com.yxtech;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * Created by winfan on 15/8/8.
 */
public class FirstServlet extends HttpServlet {

    private static final long serialVersionUID = 1L;

    public void init() throws ServletException {
        System.out.println("初始化 init()");
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("调用doGet方法");
        //设置响应的页面类别与页面的编码
        response.setContentType("text/html;charset=gbk");
        PrintWriter out = response.getWriter();
        for (int i = 1; i <=100 ; i++) {
            out.println("<br/>");
            for (int j = 1; j <= i; j++) {
                out.println(i+"+"+j+"="+(i+j));
            }
        }
        out.flush();
        out.close();

    }

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    public void destory() {
        System.out.println("调用 destory()方法");
    }

}
